#!/usr/bin/env python3
"""
股票分析应用启动脚本
"""

import os
import sys
from app import app

def main():
    """启动Flask应用"""
    print("🚀 启动股票分析服务...")
    print("📊 后端服务地址: http://localhost:5000")
    print("🔗 API文档: http://localhost:5000/api/health")
    print("⚠️  按 Ctrl+C 停止服务")

    try:
        port = int(os.environ.get('PORT', 5000))
        # from gevent.pywsgi import WSGIServer
        # http_server = WSGIServer(('0.0.0.0', 5000), app)
        # http_server.serve_forever()
        app.run(host='0.0.0.0', port=port, debug=True)
    except KeyboardInterrupt:
        print("\n👋 服务已停止")
        sys.exit(0)
    except Exception as e:
        print(f"❌ 启动失败: {e}")
        sys.exit(1)

if __name__ == '__main__':
    main()
